/**
 *  判断是否是对称树
 */
import {Tree} from './base-tree.js'
const BaseTree = new Tree()
BaseTree.insert(1)
BaseTree.insert(2)
BaseTree.insert(2)
BaseTree.insert(4)
BaseTree.insert(3)
BaseTree.insert(3)
BaseTree.insert(4)

function isSymmetrical(pRoot){
    return isSymmetricalTree(pRoot,pRoot)
}

function isSymmetricalTree(node1,node2){
    if(!node1 && !node2){
        return true
    }
    if(!node1 || !node2){
        return false
    }
    if(node1.val != node2.val){
        return false
    }
    return isSymmetricalTree(node1.left,node2.right) && isSymmetricalTree(node1.right,node2.left)
}
// console.log(BaseTree.root);
// console.log(isSymmetrical(BaseTree.root));
// console.log(BaseTree.preOrder(BaseTree.root));
